package cn.tedu.mall.front.controller;

import cn.tedu.mall.common.restful.JsonResult;
import cn.tedu.mall.front.service.IFrontCategoryService;
import cn.tedu.mall.pojo.front.entity.FrontCategoryEntity;
import cn.tedu.mall.pojo.front.vo.FrontCategoryTreeVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class FrontCategoryController {
    /**
     * 读取当前数据库中所有分类数据
     * 并且整理成树状,一级包着二级 二级又包着三级
     * 返回.根据接口文件三要素
     */
    @Autowired
    private IFrontCategoryService frontCategoryService;
    @GetMapping("/front/category/all")
    public JsonResult<FrontCategoryTreeVO<FrontCategoryEntity>> categoryTree(){
        FrontCategoryTreeVO frontCategoryTreeVO = frontCategoryService.categoryTree();
        /*JsonResult result=new JsonResult();
        result.setState(200);
        result.setMessage("ok");
        result.setData(frontCategoryTreeVO);*/
        return JsonResult.ok(frontCategoryTreeVO);
    }
}
